/services/players

  • module
services/players

{function()}

 

GET /services/players

Gets players from the database

GET /services/games?
    where[playerId]=5&
    sortBy=startRank

Parameters

  1. where {Object}Optional

    Clause used to filter which players are returned.

  2. sortBy {String}Optional

    Clause used to sort the returned players

Returns

{JSON}

An object that contains the player data:

{data: [{
    id: Int,
    name: String,       // Player name
    weight: Int,            // Player weight, in lbs
    height: Int,            // Player height, in inches
    birthday: Date,         // Player birthday
    profile: String,    // Player description/bio
    startRank: String   // Starting Rank
}]}

POST /services/players

Adds a player to the database. Only admins are allowed to create players.

POST /services/players
     {
       "name": "Harper Lee",
       "weight": 190,
       "height": 72,
       "birthday": "1990-01-22",
       "profile": "Author of 'To Kill a Mockingbird'",
       "startRank": "novice"
     }

Parameters

  1. JSONBody {JSON}

    The Raw JSON properties of a player object

Returns

{JSON}

Returns JSON with all the properties of the newly created object, including its id

{
  "id": 9,
  "name": "Harper Lee",
  "weight": 190,
  "height": 72,
  "birthday": "1990-01-22",
  "profile": "Author of 'To Kill a Mockingbird'",
  "startRank": "novice"
}

GET /services/players/:id

Gets a player by id from the database.

GET /services/players/9

Returns

{JSON}

An object that contains the player data:

{data: [{
     id: Int,
     name: String,      // Player name
     weight: Int,       // Player weight, in lbs
     height: Int,       // Player height, in inches
     birthday: Date         // Player birthday
     profile: String    // Player description/bio
     startRank: String  // Starting Rank
}]}

PUT /services/players/:id

Updates a player in the database. Only admins are allowed to update players.

PUT /services/players/9
    {
      "name": "Harper Lee",
         "weight": 190,
         "height": 72,
         "birthday": "1990-01-22",
         "profile": "Author of 'To Kill a Mockingbird' and `Absalom, Absalom`",
         "startRank": "novice"
       }

Parameters

  1. JSONBody {JSON}

    The updated properties of the player object

Returns

{JSON}

Returns JSON with all the properties of the updated object, including its id.

{
  "name": "Harper Lee",
  "weight": 190,
  "height": 72,
  "birthday": "1990-01-22",
  "profile": "Author of 'To Kill a Mockingbird' and `Absalom, Absalom`",
  "startRank": "novice"
}

DELETE /services/players/:id

Deletes a player in the database. Only admins are allowed to delete players.

DELETE /services/players/9

Returns

{JSON}

Returns and empty JSON object.

{}